package com.suxin.controller;

import com.suxin.domain.Goods;
import com.suxin.test.GoodsMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;

/**
 * @author Tang
 * @classname TestController
 * @description [  ]
 * @date 2021/8/3 22:41
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @Resource
    GoodsMapper goodsMapper;

    @GetMapping("/index")
    public List<Goods> index() {
        LocalDateTime localDateTime = LocalDateTime.now().plusMonths(-1);
        LocalDateTime startLocalDateTime = localDateTime.withHour(0).withMinute(0).withSecond(0);
        Date startDate = Date.from(startLocalDateTime.atZone(ZoneId.systemDefault()).toInstant());
        // 结束时间
        LocalDateTime endLocalDateTime = localDateTime.withHour(0).withMinute(30).withSecond(0);
        Date endDate = Date.from(endLocalDateTime.atZone(ZoneId.systemDefault()).toInstant());
        return goodsMapper.findAllByCreateTime(startDate,endDate);
    }

}